package cn.com.huzo.webapp.controller.tech;

import cn.com.huzo.model.entities.tech.PieceYardageCatalogueEntity;
import huzofw.common.web.controller.BaseFormController;
import cn.com.huzo.model.entities.tech.PieceYardageHeaderEntity;
import cn.com.huzo.model.entities.tech.PieceYardageLinesEntity;
import cn.com.huzo.model.entities.tech.PieceYardageLinesProductColourEntity;
import cn.com.huzo.model.entities.tech.PieceYardageLinesProductSizeEntity;
import cn.com.huzo.service.tech.PieceYardageCatalogueManager;
import cn.com.huzo.service.tech.PieceYardageHeaderManager;
import cn.com.huzo.service.tech.PieceYardageLinesManager;
import cn.com.huzo.service.tech.PieceYardageLinesProductColourManager;
import cn.com.huzo.service.tech.PieceYardageLinesProductSizeManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * 单耗信息控制器
 *
 * @author 吴旭
 */
@Controller
public class PieceYardageController extends BaseFormController {

    // <editor-fold defaultstate="collapsed" desc="属性">
    @Resource(name = "PieceYardageCatalogueManager")
    private PieceYardageCatalogueManager _manager_catalogue;

    @Resource(name = "PieceYardageHeaderManager")
    private PieceYardageHeaderManager _manager_header;

    @Resource(name = "PieceYardageLinesManager")
    private PieceYardageLinesManager _manager_lines;

    @Resource(name = "PieceYardageLinesProductColourManager")
    private PieceYardageLinesProductColourManager _manager_lines_product_colour;

    @Resource(name = "PieceYardageLinesProductSizeManager")
    private PieceYardageLinesProductSizeManager _manager_lines_product_size;
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="画面处理部分">
    /**
     * 跳转到单耗（设计）一览画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/design/list.html")
    public ModelAndView redirectDesignListWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("tech.piece_yardage_onesize_design.list.def");
        return view;
    }

    /**
     * 跳转到单耗（均码推版）一览画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/grading/list.html")
    public ModelAndView redirectOneSizeGradingListWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("tech.piece_yardage_onesize_grading.list.def");
        return view;
    }

    /**
     * 跳转到单耗（全码推版）一览画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_fullsize/grading/list.html")
    public ModelAndView redirectFullSizeGradingListWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("tech.piece_yardage_fullsize_grading.list.def");
        return view;
    }

    /**
     * 跳转到单耗（副资材）一览画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/auxiliary/list.html")
    public ModelAndView redirectAuxiliaryListWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("tech.piece_yardage_onesize_auxiliary.list.def");
        return view;
    }

    /**
     * 跳转单耗（设计）编辑画面
     * <p>
     * @param action 操作类别 1：增加 2：编辑
     * @param bomId 单耗标识
     * @param nodeId 所属目录标识
     * @return
     * @throws java.lang.Exception
     */
    @RequestMapping("tech/piece_yardage_onesize/design/{action}/{bomId}/{nodeId}/edit.html")
    public ModelAndView redirectDesignEditWnd(@PathVariable(value = "action") int action,
            @PathVariable(value = "bomId") Long bomId,
            @PathVariable(value = "nodeId") Long nodeId) throws Exception {
        ModelAndView view = new ModelAndView();
        // 为画面设置变量
        view.addObject("action", action);
        view.addObject("bomId", bomId);

        if (nodeId != 0L) {
            PieceYardageCatalogueEntity _item = _manager_catalogue.fetchByKey(nodeId);
            view.addObject("nodeId", nodeId);
            view.addObject("nodeText", _item.getParentName() + " → " + _item.getCatalogueName());
        }

        view.setViewName("tech.piece_yardage_onesize_design.edit.def");
        return view;
    }

    /**
     * 跳转单耗（均码推版）编辑画面
     * <p>
     * @param action 操作类别 1：增加 2：编辑
     * @param bomId 单耗标识
     * @param nodeId 所属目录标识
     * @return
     * @throws java.lang.Exception
     */
    @RequestMapping("tech/piece_yardage_onesize/grading/{action}/{bomId}/{nodeId}/edit.html")
    public ModelAndView redirectOneSizeGradingEditWnd(@PathVariable(value = "action") int action,
            @PathVariable(value = "bomId") Long bomId,
            @PathVariable(value = "nodeId") Long nodeId) throws Exception {
        ModelAndView view = new ModelAndView();
        // 为画面设置变量
        view.addObject("action", action);
        view.addObject("bomId", bomId);

        if (nodeId != 0L) {
            PieceYardageCatalogueEntity _item = _manager_catalogue.fetchByKey(nodeId);
            view.addObject("nodeId", nodeId);
            view.addObject("nodeText", _item.getParentName() + " → " + _item.getCatalogueName());
        }

        view.setViewName("tech.piece_yardage_onesize_grading.edit.def");
        return view;
    }

    /**
     * 跳转单耗（全码推版）编辑画面
     * <p>
     * @param action 操作类别 1：增加 2：编辑
     * @param bomId 单耗标识
     * @param nodeId 所属目录标识
     * @return
     * @throws java.lang.Exception
     */
    @RequestMapping("tech/piece_yardage_fullsize/grading/{action}/{bomId}/{nodeId}/edit.html")
    public ModelAndView redirectFullSizeGradingEditWnd(@PathVariable(value = "action") int action,
            @PathVariable(value = "bomId") Long bomId,
            @PathVariable(value = "nodeId") Long nodeId) throws Exception {
        ModelAndView view = new ModelAndView();
        // 为画面设置变量
        view.addObject("action", action);
        view.addObject("bomId", bomId);

        if (nodeId != 0L) {
            PieceYardageCatalogueEntity _item = _manager_catalogue.fetchByKey(nodeId);
            view.addObject("nodeId", nodeId);
            view.addObject("nodeText", _item.getParentName() + " → " + _item.getCatalogueName());
        }

        view.setViewName("tech.piece_yardage_fullsize_grading.edit.def");
        return view;
    }

    /**
     * 跳转单耗（副资材）编辑画面
     * <p>
     * @param action 操作类别 1：增加 2：编辑
     * @param bomId 单耗标识
     * @param nodeId 所属目录标识
     * @return
     * @throws java.lang.Exception
     */
    @RequestMapping("tech/piece_yardage_onesize/auxiliary/{action}/{bomId}/{nodeId}/edit.html")
    public ModelAndView redirectAuxiliaryEditWnd(@PathVariable(value = "action") int action,
            @PathVariable(value = "bomId") Long bomId,
            @PathVariable(value = "nodeId") Long nodeId) throws Exception {
        ModelAndView view = new ModelAndView();
        // 为画面设置变量
        view.addObject("action", action);
        view.addObject("bomId", bomId);

        if (nodeId != 0L) {
            PieceYardageCatalogueEntity _item = _manager_catalogue.fetchByKey(nodeId);
            view.addObject("nodeId", nodeId);
            view.addObject("nodeText", _item.getParentName() + " → " + _item.getCatalogueName());
        }

        view.setViewName("tech.piece_yardage_onesize_auxiliary.edit.def");
        return view;
    }

    /**
     * 弹出单耗选择画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/choice.html")
    public ModelAndView redirectPieceYardagePopupWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("popup.tech.piece_yardage_onesize.choice.def");
        return view;
    }

    /**
     * 编辑单耗配色用成品色（为了同步生产指示书）
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/lines/product_colour/edit.html")
    public ModelAndView redirectPieceYardageLinesProductColourPopupWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("popup.tech.piece_yardage_onesize_lines_product_colour.edit.def");
        return view;
    }

    /**
     * 批量更改材料色画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/lines/material_colour/edit.html")
    public ModelAndView redirectPieceYardageLinesMaterialColourPopupWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("popup.tech.piece_yardage_onesize_lines_material_colour.edit.def");
        return view;
    }

    /**
     * 编辑全码单耗用成品尺码（为了同步生产指示书）
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage/lines/product_size/edit.html")
    public ModelAndView redirectPieceYardageLinesProducSizePopupWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("popup.tech.piece_yardage_lines_product_size.edit.def");
        return view;
    }
    
    /**
     * 单耗表打印预览画面
     * <p>
     * @return
     */
    @RequestMapping("tech/piece_yardage_onesize/print.html")
    public ModelAndView redirectPrintPreviewWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("print.tech.piece_yardage_onesize.print.def");
        return view;
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="主表-数据处理部分">
    /**
     * 根据标识取得单耗数据。
     *
     * @param criterion 单耗标识、当前用户、流程标识
     * @return 单耗数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/fetchByKey.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> fetchByKey(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_header.fetchByHeaderKey(MapUtils.getLong(criterion, "HeaderId"));
    }

    /**
     * 根据款号取得单耗数据。
     *
     * @param criterion 款号、单耗类型
     * @return 单耗数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/fetchByStyleNo.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageHeaderEntity> fetchByStyleNo(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_header.fetchByStyleNo(criterion);
    }

    /**
     * 删除单耗信息数据。
     *
     * @param criterion 要删除的数据
     * @return 删除后的数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> delete(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_header.delete(criterion);
    }

    /**
     * 根据条件取得单耗信息分页数据。
     * <p>
     * @param criterion 检索条件
     * @return 单耗信息分页数据
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/fetchForPage.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> fetchForPage(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_header.fetchForPage(criterion);
    }

    /**
     * 新增单耗信息数据。
     * <p>
     * @param instance 要保存的单耗信息对象。
     * @return 新增记录ID及相关明细数据
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/header/insert.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> add(@RequestBody final PieceYardageHeaderEntity instance) throws Exception {
        return _manager_header.add(instance);
    }

    /**
     * 更新单耗信息数据。
     * <p>
     * @param instance 要保存的单耗信息对象。
     * @return 新增记录主键.
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/header/update.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Integer update(@RequestBody final PieceYardageHeaderEntity instance) throws Exception {
        return _manager_header.update(instance);
    }

    /**
     * 更新单耗员所属的信息数据（ic色样、其他单耗、以及技术员）。
     * <p>
     * @param instance 要保存的单耗信息对象。
     * @return 新增记录主键.
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/header/updateGrading.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Integer updateGrading(@RequestBody final PieceYardageHeaderEntity instance) throws Exception {
        return _manager_header.updateGradedBy(instance);
    }

    /**
     * 批量更新所属目录。
     *
     * @param itemList 要处理的数据列表
     * @return
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/changeCatalogue.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Integer batchChangeCatalogue(@RequestBody final Map<String, ? extends List<PieceYardageHeaderEntity>> itemList) throws Exception {
        int rowsAffected = 0;
        if (itemList.get("updateList").size() > 0) {
            rowsAffected = _manager_header.batchChangeCatalogue(itemList.get("updateList"));
        }

        return rowsAffected;
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="明细-数据处理部分">
    /**
     * 根据主表标识，取得明细表数据。
     *
     * @param headerId 单耗ID
     * @return 明细列表数据
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/fetchLinesByHeaderKey.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> fetchLinesByHeaderKey(@RequestBody final Long headerId) throws Exception {
        return _manager_lines.fetchLinesByHeaderKey(headerId);
    }

    /**
     * 增加明细数据。
     *
     * @param instance 标识
     * @return 增加后的单耗明细
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/insert.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> insertLines(@RequestBody final List<PieceYardageLinesEntity> instance) throws Exception {
        return _manager_lines.insertLines(instance);
    }

    /**
     * 更新明细数据。
     *
     * @param itemList 要保存的数据
     * @return 更新后的单耗明细
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/update.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateLines(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        if (itemList != null && !itemList.isEmpty()) {
            return _manager_lines.updateLines(itemList);
        } else {
            return new HashMap();
        }
    }

    /**
     * 根据料号更该明细材料数据。
     *
     * @param criterion 要更新的数据（行标识、料号）
     * @return 更新后的单耗明细。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/updateLinesByMaterialId.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateLinesByMaterialId(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_lines.updateLinesByMaterialId(
                MapUtils.getLong(criterion, "HeaderId"),
                MapUtils.getString(criterion, "LinesId"),
                MapUtils.getLong(criterion, "MaterialId"),
                MapUtils.getLong(criterion, "UpdatedBy")
        );
    }

    /**
     * 删除明细数据。
     *
     * @param criterion 要删除的明细标识、主表id、删除的明细信息等
     * @return 删除后的数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> deleteLines(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_lines.delete(criterion);
    }

    /**
     * 批量删除明细数据。
     *
     * @param itemList 单耗明细标识
     * @return 删除后的数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/batch_delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> batchDeleteLines(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        return _manager_lines.batchDeleteLines(itemList);
    }

    /**
     * 批量清空单耗数据。
     *
     * @param itemList 单耗明细标识
     * @return 清空后单耗明细数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/batchClearLinesPieceYardage.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> batchClearLinesPieceYardage(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        if (itemList != null && !itemList.isEmpty()) {
            return _manager_lines.batchClearLinesPieceYardage(itemList);
        } else {
            return new ArrayList();
        }
    }

    /**
     * 批量清空尺码单耗数据。
     *
     * @param itemList 单耗明细标识
     * @return 清空后单耗明细数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/sizegrade/clear.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> batchClearLinesSizePieceYardage(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        if (itemList != null && !itemList.isEmpty()) {
            return _manager_lines.batchClearLinesSizePieceYardage(itemList);
        } else {
            return new ArrayList();
        }
    }

    /**
     * 引入类似款号的单耗明细。
     *
     * @param criterion 要引入的单耗
     * @return 引入后的单耗明细
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/importLinesFromOtherBom.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> importLinesFromOtherBom(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_lines.importLinesFromOtherBom(
                MapUtils.getLong(criterion, "HeaderId"),
                MapUtils.getLong(criterion, "ImportedBomHeaderId"),
                MapUtils.getLong(criterion, "CreatedBy"),
                MapUtils.getLong(criterion, "UpdatedBy"));
    }

    /**
     * 从剪切板粘贴数据。
     *
     * @param criterion 剪切板数据
     * @return 粘贴后的单耗明细。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/paste.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> insertFromClipboard(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager_lines.insertFromClipboard(
                MapUtils.getLong(criterion, "HeaderId"),
                MapUtils.getString(criterion, "CopiedLinesId"),
                MapUtils.getLong(criterion, "MaterialId"),
                MapUtils.getLong(criterion, "UomId"),
                MapUtils.getString(criterion, "Specification"),
                MapUtils.getInteger(criterion, "OrderNo"),
                MapUtils.getLong(criterion, "CreatedBy"),
                MapUtils.getLong(criterion, "UpdatedBy"));
    }

    /**
     * 更新明细单用量（均码推板工作）。
     *
     * @param itemList 要保存的数据
     * @return 单耗明细。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/grade.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateLinesGrade(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        if (itemList != null && !itemList.isEmpty()) {
            return _manager_lines.updateLinesGrade(itemList);
        } else {
            return new HashMap();
        }
    }

    /**
     * 更新明细尺码单用量（全码推板工作）。
     *
     * @param itemList 要保存的数据
     * @return 单耗明细。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/sizegrade/update.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateLinesSizeGrade(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        if (itemList != null && !itemList.isEmpty()) {
            return _manager_lines.updateLinesSizeGrade(itemList);
        } else {
            return new HashMap();
        }
    }

    /**
     * 更新单耗明细排列顺序。
     *
     * @param itemList 要更新单耗明细列表
     * @return 影响行数
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "/tech/piece_yardage_onesize/lines/updateLinesOrder.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateLinesOrder(@RequestBody final List<PieceYardageLinesEntity> itemList) throws Exception {
        return _manager_lines.updateLinesOrder(itemList);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="明细-成品色以及颜色搭配数据处理部分">
    /**
     * 根据主表标识，取得配色用成品色表数据。
     *
     * @param headerId 单耗ID
     * @return 搭配用成品色
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/product_colour/fetchByHeaderKey.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesProductColourEntity> fetchLinesProductColourByHeaderKey(@RequestBody final Long headerId) throws Exception {
        return _manager_lines_product_colour.fetchByHeaderKey(headerId);
    }

    /**
     * 增加配色用成品色。
     *
     * @param itemList 要增加的数据
     * @return 搭配用成品色、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/product_colour/insert.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> insertProductColour(@RequestBody final List<PieceYardageLinesProductColourEntity> itemList) throws Exception {
        return _manager_lines_product_colour.batchInsert(itemList);
    }

    /**
     * 编辑配色的成品色。
     *
     * @param itemList 要编辑的数据
     * @return 搭配用成品色、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/product_colour/changeProductColour.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> changeProductColour(@RequestBody final List<PieceYardageLinesProductColourEntity> itemList) throws Exception {
        return _manager_lines_product_colour.batchUpdate(itemList);
    }

    /**
     * 删除配色用成品色。
     *
     * @param instance 要删除的数据
     * @return 搭配用成品色、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/product_colour/delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> deleteProductColour(@RequestBody final PieceYardageLinesProductColourEntity instance) throws Exception {
        return _manager_lines_product_colour.deleteLines(instance);
    }

    /**
     * 拖动行改变成品色显示顺序。
     *
     * @param itemList 要改变的数据
     * @return 搭配用成品色、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/product_colour/updateLinesOrder.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateProductColourLinesOrder(@RequestBody final List<PieceYardageLinesProductColourEntity> itemList) throws Exception {
        return _manager_lines_product_colour.updateProductColourOrder(itemList);
    }

    /**
     * 批量更改材料色。
     *
     * @param itemList 要改变的配色的数据
     * @return 单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onesize/lines/material_colour/update.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesEntity> batchUpdateMaterialColour(@RequestBody final List<Map<String, Object>> itemList) throws Exception {
        return _manager_lines.batchChangeMaterialColour(itemList);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="明细-成品尺码数据处理部分">
    /**
     * 根据主表标识，取得配色用成品色尺码数据。
     *
     * @param headerId 单耗ID
     * @return 明细列表数据
     * @throws Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/product_size/fetchByHeaderId.html",
            method = RequestMethod.POST)
    public @ResponseBody
    List<PieceYardageLinesProductSizeEntity> fetchLinesProductSizeByHeaderId(@RequestBody final Long headerId) throws Exception {
        return _manager_lines_product_size.fetchByHeaderId(headerId);
    }

    /**
     * 增加全码单耗用成品尺码。
     *
     * @param itemList 要增加的数据
     * @return 单耗明细
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/product_size/insert.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> insertProductSize(@RequestBody final List<PieceYardageLinesProductSizeEntity> itemList) throws Exception {
        return _manager_lines_product_size.insert(itemList);
    }

    /**
     * 编辑全码单耗的成品尺码。
     *
     * @param itemList 要编辑的数据
     * @return 搭配用成品码、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/product_size/update.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> updateProductSize(@RequestBody final List<PieceYardageLinesProductSizeEntity> itemList) throws Exception {
        return _manager_lines_product_size.update(itemList);
    }

    /**
     * 删除配色用成品色。
     *
     * @param instance 要删除的数据
     * @return 搭配用成品码、单耗明细等
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_lines/product_size/delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> deleteProductSize(@RequestBody final PieceYardageLinesProductSizeEntity instance) throws Exception {
        return _manager_lines_product_size.deleteLines(instance);
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="打印处理部分">
    /**
     * 取得打印数据
     *
     * @param headerId 单耗ID
     * @return 打印数据
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "tech/piece_yardage_onsize/print/fetch.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> fetchPrintData(@RequestBody final Long headerId) throws Exception {
        return _manager_header.fetchPrintData(headerId);
    }
    // </editor-fold>
}
